// import { init } from "tinymce";

function url(r) {
  return `${window.RPConfig.mgt}/group/${r}`;
  // return `/group/${r}`
}
function url_group(r) {
  return `${window.RPConfig.userCenter}/group/${r}`;
  // return `/group/${r}`
}

// 查询用户组列表
// export const findGroupList = ({ responseProcess, param, initParam }) => {
//   const _param = Object.assign({}, param, initParam);
//   $http.post(url_group("page"), _param).then(res => {
//     responseProcess(res.data);
//   });
// };
export function findGroupList({ responseProcess, param, initParam }) {
  const _param = Object.assign({}, param, initParam);
  $http.post(url_group("page"), _param).then(res => {
    // 状态为有效：禁用复选框，不可删除
    let { records } = res.data;
    records = this.$root.$options.filters["selection-disabled"](records);
    responseProcess(res.data);
  });
}

// 添加用户组
export const addUserGroup = param => $http.post(url_group(param.id ? "update" : "add"), param);

// 删除用户组
export const deleteUserGroup = ids => $http.post(url_group("delete"), ids);

// 查询组人员列表
export const findGroupPersonList = param => {
  return $http.post(url_group("user/page"), param).then(res => res.data);
};

// 查询待选用户列表
export const findOtherPersonList = param => {
  return $http.post(url_group("user/assign/page"), param).then(res => res.data);
};

// 添加用户组成员
export const addGroupPersonList = params => $http.post(url_group("user/add"), params);

// 更新人员信息
export const updateGroupPersonList = params => $http.post(url("employee/update"), params);

// delete
export const delGroupPersonList = id => $http.post(url_group("user/delete"), id);
